home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Tools&Utilities / EnterAct Stuff / Drag_on Modules / hAWK example progs / $AcroTester next >
Text File  |  1994-01-26  |  724b  |  25 lines

  1. BEGIN {    find = "(^|[^@])([A-Z][A-Z]+)"
  2.     rep["CA"] = "California"
  3.     rep["HYPO"] = "hypobetalipoproteinemia"
  4.     rep["RE"] = "regular expression"
  5.     #...etc...
  6.     rep["SOM"] = "osoma"
  7.     }
  8. {loopCount = 0;
  9.     while (match($0, find) && loopCount++ < 50)
  10.         {
  11.         acronym= substr($0, RSTART, RLENGTH)
  12.         sub(find, "\2", acronym)
  13.         ##gsub(/[^A-Z@#]/, "", acronym)
  14.         if (acronym in rep)
  15.             sub(find, "\1" rep[acronym])#replace acronym by expansion
  16.         else
  17.             sub(find, "\1@#@\2")#stick '@#@' in front of unknown acronym
  18.         }
  19.     if (loopCount >= 50)
  20.         {
  21.         print "The acronym", acronym, "is looping forever." ; exit
  22.         }
  23.     gsub(/@#@/, "")#trim the protector by replacing it with null string
  24.     print >> (STDPATH "junker")#print the altered line to stdout
  25.     }